#ifndef UNIX_DAEMON_H
#define UNIX_DAEMON_H

#include <QtCore/QFile>
#include "kernel/kernel.h"

namespace smsbilling {

class UnixDaemon : public QObject {
  Q_OBJECT
public:

  UnixDaemon(const QString &config_file);

  ~UnixDaemon();

  void daemonize();

  static void messageHandler(QtMsgType type, const char *msg);

#ifdef Q_OS_UNIX
  static void signalHandler(int signal);
#endif

private slots:

  void kernelStateChanged(State state);

private:

  void createWorkerData();

  void destroyWorkerData();

#ifdef Q_OS_UNIX
  int pid_file;
#endif

  QString config_file_path;

  LogEncoder *log_encoder;

  QSettings *config;

  Kernel *kernel;
};

} // namespace smsbilling

#endif // UNIX_DAEMON_H
